home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
art&graf.ix
/
art-0039
/
source
/
dcdpalet.mod
< prev
next >
Wrap
Text File
|
1997-04-16
|
16KB
|
476 lines
IMPLEMENTATION MODULE DCDPalette;
(*--------------------------------------------------------------------*)
(* *)
(* This library module is reponsible for processing palette dialogs *)
(* for DegasConvert. This module will show the dialogue, return *)
(* the input but will NOT clean up the screen. The calling program *)
(* is reponsible for that. *)
(* *)
(* Amendments: *)
(* *)
(* August 1988 L.G.Miller *)
(* :- add pixel dialog *)
(* *)
(* *)
(* August 1987 L.G.Miller *)
(* *)
(* *)
(* 25/ 8/89 LGM : Use new picture conversion routines. *)
(* *)
(*--------------------------------------------------------------------*)
(* IMPORT Trace; *)
FROM DCGlobal IMPORT (* CONST *)
LowRes,
MedRes,
HiRes,
DegasPicture,
PaletteEntry,
PrintPalette,
BITSPERWORD;
IMPORT DCPicCnv;
FROM SYSTEM IMPORT ADDRESS, ADR;
FROM Strings IMPORT String, Assign, Concat, Length;
FROM GemObjects IMPORT TreePointer, GetObjectSpec, SelectObject,
DeselectObject, GetTEDData, SetTEDData,
GetState, SetState;
IMPORT Object;
IMPORT Forms;
FROM Forms IMPORT DialAction;
FROM ManyWindow IMPORT
(* VAR *)
AESApplId, (* AES handle for this application *)
VDIHandle, (* VDI handle of current Virtual Workstation *)
ShowMouse,
HideMouse;
FROM Dcrsc IMPORT
paletbox, (* dialogue box for getting print bit patterns *)
prgb000, pindex00, ppat000,
prgb001, pindex01, ppat001,
prgb002, pindex02, ppat002,
prgb003, pindex03, ppat003,
prgb004, pindex04, ppat004,
prgb005, pindex05, ppat005,
prgb006, pindex06, ppat006,
prgb007, pindex07, ppat007,
prgb008, pindex08, ppat008,
prgb009, pindex09, ppat009,
prgb010, pindex10, ppat010,
prgb011, pindex11, ppat011,
prgb012, pindex12, ppat012,
prgb013, pindex13, ppat013,
prgb014, pindex14, ppat014,
prgb015, pindex15, ppat015,
ppalok, (* ok box for palette *)
ppalcan, (* cancel box for palette *)
(*----------------------------------------------------------------------*)
(* constants for the pixel enquiry/update dialog *)
(*----------------------------------------------------------------------*)
dpixel, (* dialog tree *)
dpixrgb,
dpixindx,
dpixpbp,
dpixok,
dpixcan;
(* -------------------- End of IMPORTS ----------------------- *)
(*----------------------------------------------------------------------*)
(* G L O B A L T Y P E S *)
(*----------------------------------------------------------------------*)
TYPE
StringPtr = POINTER TO String; (* null terminated *)
DialogLine = (* object numbers *)
RECORD
rgbcomp,
lineno,
pattern : INTEGER;
END;
(*----------------------------------------------------------------------*)
(* low-level dialog line routine to clear an entry and protect it *)
(*----------------------------------------------------------------------*)
PROCEDURE ClearPrintDialogLine ( VAR dline : DialogLine;
dtreei : INTEGER );
VAR sptr : StringPtr;
BEGIN
sptr := GetObjectSpec( dtreei, dline.rgbcomp );
Assign(' ', sptr^);
sptr := GetObjectSpec( dtreei, dline.lineno );
Assign(' ', sptr^);
SetTEDData( dtreei, dline.pattern, ' ' );
END ClearPrintDialogLine;
(*----------------------------------------------------------------------*)
(* low-level dialog line routine to load an entry *)
(*----------------------------------------------------------------------*)
PROCEDURE LoadPrintDialogLine ( VAR dline : DialogLine;
pentry : PaletteEntry;
dtreei : INTEGER;
res : CARDINAL );
VAR sptr : StringPtr;
tedptr : POINTER TO Object.TEDINFO;
tstr, nstr : String;
i : INTEGER;
flags : BITSET;
BEGIN
Assign( '000',tstr);
tstr[0] := CHR( ORD('0') + CARDINAL(pentry.RedComponent) );
tstr[1] := CHR( ORD('0') + CARDINAL(pentry.GreenComponent) );
tstr[2] := CHR( ORD('0') + CARDINAL(pentry.BlueComponent) );
sptr := GetObjectSpec( dtreei, dline.rgbcomp );
Assign(tstr, sptr^);
(* simple way of converting a number to a two digit string *)
Assign('00010203040506070809101112131415', nstr);
Assign('00', tstr);
tstr[0] := nstr[ (pentry.ColourIndex * 2) ];
tstr[1] := nstr[ (pentry.ColourIndex * 2) + 1 ];
sptr := GetObjectSpec( dtreei, dline.lineno );
Assign(tstr, sptr^);
(*----------------------------------------------------------------------*)
(* The pattern string is a TEDinfo structure and will need dereferencing*)
(*----------------------------------------------------------------------*)
tedptr := GetObjectSpec( dtreei, dline.pattern );
SetState( dtreei, dline.pattern, Object.ObjectStates{} );
IF res = MedRes THEN
Assign('00', tstr);
IF 0 IN pentry.PrintBitPattern THEN tstr[1] := '1' END;
IF 1 IN pentry.PrintBitPattern THEN tstr[0] := '1' END;
sptr := tedptr^.te_ptext;
Assign(tstr, sptr^);
sptr := tedptr^.te_ptmplt;
Assign('__',sptr^);
sptr := tedptr^.te_pvalid;
Assign('99',sptr^);
tedptr^.te_txtlen := 3;
tedptr^.te_tmplen := 3;
ELSE
Assign('0000', tstr);
IF 0 IN pentry.PrintBitPattern THEN tstr[3] := '1' END;
IF 1 IN pentry.PrintBitPattern THEN tstr[2] := '1' END;
IF 2 IN pentry.PrintBitPattern THEN tstr[1] := '1' END;
IF 3 IN pentry.PrintBitPattern THEN tstr[0] := '1' END;
sptr := tedptr^.te_ptext;
Assign(tstr, sptr^);
sptr := tedptr^.te_ptmplt;
Assign('____', sptr^);
sptr := tedptr^.te_pvalid;
Assign('9999', sptr^);
tedptr^.te_txtlen := 5;
tedptr^.te_tmplen := 5;
END; (* if *)
END LoadPrintDialogLine;
(*----------------------------------------------------------------------*)
(* return the print pattern from one line of the dialog ( in pentry ) *)
(*----------------------------------------------------------------------*)
PROCEDURE GetDialogPrintPattern( VAR dline : DialogLine;
VAR pentry : PaletteEntry;
dtreei : INTEGER;
res : CARDINAL );
VAR sptr : StringPtr;
tedptr : POINTER TO Object.TEDINFO;
tstr, nstr : String;
i, lim : INTEGER;
BEGIN
tedptr := GetObjectSpec( dtreei, dline.pattern );
sptr := tedptr^.te_ptext;
Assign(sptr^, tstr);
Concat(tstr,'0000',tstr);
IF res = MedRes THEN
lim := 1;
ELSE
lim := 3;
END;
FOR i := 0 TO lim DO
IF tstr[i] = '0' THEN
EXCL(pentry.PrintBitPattern, (lim-i));
ELSE
INCL(pentry.PrintBitPattern, (lim-i));
END; (* if *)
END; (* for i *)
END GetDialogPrintPattern;
(*----------------------------------------------------------------------*)
(* Clear Dialog Tree of current values and protect all entries *)
(*----------------------------------------------------------------------*)
PROCEDURE ResetDialog ( VAR dlines : ARRAY OF DialogLine;
VAR pentries : PrintPalette;
dtreei : INTEGER;
res : INTEGER );
VAR i, lim : INTEGER;
BEGIN
FOR i := 0 TO SHORT(HIGH(dlines)) DO
ClearPrintDialogLine( dlines[i], dtreei);
END; (* for *)
lim := SHORT(HIGH(dlines));
IF res = MedRes THEN
lim := 3;
END;
FOR i := 0 TO lim DO
LoadPrintDialogLine( dlines[i], pentries[i], dtreei, res );
END; (* for *)
END ResetDialog;
(*----------------------------------------------------------------------*)
(* Load array with object numbers of the components of a line of dialog *)
(*----------------------------------------------------------------------*)
PROCEDURE InitArray( VAR objectsarray : ARRAY OF DialogLine );
BEGIN
WITH objectsarray[0] DO
rgbcomp := prgb000;
lineno := pindex00;
pattern := ppat000;
END;
WITH objectsarray[1] DO
rgbcomp := prgb001;
lineno := pindex01;
pattern := ppat001;
END;
WITH objectsarray[2] DO
rgbcomp := prgb002;
lineno := pindex02;
pattern := ppat002;
END;
WITH objectsarray[3] DO
rgbcomp := prgb003;
lineno := pindex03;
pattern := ppat003;
END;
WITH objectsarray[4] DO
rgbcomp := prgb004;
lineno := pindex04;
pattern := ppat004;
END;
WITH objectsarray[5] DO
rgbcomp := prgb005;
lineno := pindex05;
pattern := ppat005;
END;
WITH objectsarray[6] DO
rgbcomp := prgb006;
lineno := pindex06;
pattern := ppat006;
END;
WITH objectsarray[7] DO
rgbcomp := prgb007;
lineno := pindex07;
pattern := ppat007;
END;
WITH objectsarray[8] DO
rgbcomp := prgb008;
lineno := pindex08;
pattern := ppat008;
END;
WITH objectsarray[9] DO
rgbcomp := prgb009;
lineno := pindex09;
pattern := ppat009;
END;
WITH objectsarray[10] DO
rgbcomp := prgb010;
lineno := pindex10;
pattern := ppat010;
END;
WITH objectsarray[11] DO
rgbcomp := prgb011;
lineno := pindex11;
pattern := ppat011;
END;
WITH objectsarray[12] DO
rgbcomp := prgb012;
lineno := pindex12;
pattern := ppat012;
END;
WITH objectsarray[13] DO
rgbcomp := prgb013;
lineno := pindex13;
pattern := ppat013;
END;
WITH objectsarray[14] DO
rgbcomp := prgb014;
lineno := pindex14;
pattern := ppat014;
END;
WITH objectsarray[15] DO
rgbcomp := prgb015;
lineno := pindex15;
pattern := ppat015;
END;
END InitArray;
(*----------------------------------------------------------------------*)
(* P I X E L D I A L O G *)
(*----------------------------------------------------------------------*)
(*----------------------------------------------------------------------*)
(* use the above print dialog routines for loading/clearing the *)
(* dpixel dialog. *)
(* Note: It is no coincidence that the DPIXEL resource structure is the *)
(* same as a DialogPrintLine Entry *)
(*----------------------------------------------------------------------*)
(*----------------------------------------------------------------------*)
(* Run dialogue to get print patterns from the user *)
(*----------------------------------------------------------------------*)
PROCEDURE DoPaletteDialog ( VAR pp : PrintPalette;
res : CARDINAL ) : BOOLEAN;
VAR i, entries : INTEGER;
dlines : ARRAY [ 0 .. 15 ] OF DialogLine;
dTree : ADDRESS ;
x, y, w, h, dumc : CARDINAL ;
result : INTEGER;
BEGIN
InitArray( dlines );
IF res = LowRes THEN
DCPicCnv.SortByColour( pp, 16 );
ELSE
DCPicCnv.SortByColour( pp, 4 );
END;
ResetDialog( dlines, pp, paletbox, INTEGER(res) );
DeselectObject(paletbox, ppalok) ;
DeselectObject(paletbox, ppalcan) ;
dTree := TreePointer( paletbox );
Forms.form_center(dTree, x, y, w, h) ;
dumc := Forms.form_dial(ReserveSpace, 0, 0, 0, 0, x, y, w, h) ;
dumc := Forms.form_dial(ExpandBox, 0, 0, 0, 0, x, y, w, h) ;
dumc := Object.objc_draw(dTree, 0, 10, x, y, w, h) ;
result := Forms.form_do(dTree, dlines[0].pattern) ;
dumc := Forms.form_dial(ShrinkBox, 0, 0, 0, 0, x, y, w, h) ;
dumc := Forms.form_dial(FreeSpace, 0, 0, 0, 0, x, y, w, h) ;
IF result = ppalok THEN
FOR i := 0 TO HIGH(pp) DO
GetDialogPrintPattern( dlines[i], pp[i], paletbox, INTEGER(res) );
END; (* for i *)
END; (* if *)
DCPicCnv.SortByIndex( pp, 16 );
RETURN ( result = ppalok );
END DoPaletteDialog;
(*----------------------------------------------------------------------*)
(* Run pixel dialog. *)
(*----------------------------------------------------------------------*)
PROCEDURE DoPixelDialog ( VAR picture : DegasPicture;
mousex, mousey,
screenres : CARDINAL;
VAR pp : PrintPalette ) ;
VAR entry : INTEGER;
dline : DialogLine;
pentry : PaletteEntry;
dTree : ADDRESS ;
x, y, w, h, dumc : CARDINAL ;
result : INTEGER;
BEGIN
WITH dline DO
rgbcomp := dpixrgb;
lineno := dpixindx;
pattern := dpixpbp;
END;
(* convert input mouse co-ords to med-res co-ords *)
IF screenres = HiRes THEN
mousey := mousey DIV 2;
END;
IF ( picture.resolution = LowRes ) THEN
mousex := mousex DIV 2;
entry := DCPicCnv.QueryXYLowResPixelIndex( mousex, mousey, picture);
ELSE
entry := DCPicCnv.QueryXYMedResPixelIndex( mousex, mousey, picture);
END;
dTree := TreePointer( dpixel );
ClearPrintDialogLine( dline, dpixel);
LoadPrintDialogLine( dline, pp[entry], dpixel, picture.resolution );
DeselectObject(dpixel, dpixok);
DeselectObject(dpixel, dpixcan);
Forms.form_center(dTree, x, y, w, h) ;
dumc := Forms.form_dial(ReserveSpace, 0, 0, 0, 0, x, y, w, h) ;
dumc := Forms.form_dial(ExpandBox, 0, 0, 0, 0, x, y, w, h) ;
dumc := Object.objc_draw(dTree, 0, 10, x, y, w, h) ;
result := Forms.form_do(dTree, dline.pattern) ;
dumc := Forms.form_dial(ShrinkBox, 0, 0, 0, 0, x, y, w, h) ;
dumc := Forms.form_dial(FreeSpace, 0, 0, 0, 0, x, y, w, h) ;
IF result = dpixok THEN
GetDialogPrintPattern( dline, pp[entry], dpixel,
picture.resolution );
END; (* if *)
END DoPixelDialog;
END DCDPalette.